package org.yy.hint;

import org.apache.shardingsphere.api.sharding.hint.HintShardingAlgorithm;
import org.apache.shardingsphere.api.sharding.hint.HintShardingValue;

import java.util.ArrayList;
import java.util.Collection;

public class MyHint implements HintShardingAlgorithm<Long> {
    @Override
    public Collection<String> doSharding(Collection<String> collection, HintShardingValue<Long> hintShardingValue) {

        ArrayList<String> list = new ArrayList<>();

        for (String name : collection) {
            for (Long value : hintShardingValue.getValues()) {
                if (name.endsWith(String.valueOf(value % 2))) {
                    list.add(name);
                }
            }
        }


        return list;
    }
}
